﻿using System;
using System.Collections.Generic;
using System.Linq;
using ExpenseSystem.Common;
using ExpenseSystem.Fether;
using ExpenseSystem.Model;
using ExpenseSystem.Lor;

namespace ExpenseSystem.Fether
{
    public class SalesBonusFetcher : NormalFetcher<SalesBonusModel>,IDetailFetcher<SalesBonusModel>
    {
        public IList<SalesBonusModel> ListByMainId( long site, long mainId, out string message, out int rows)
        {
            IList<SalesBonusModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out  rows, Restrain.Eq("CustomerId", mainId));
            return result;
        }
        public IList<SalesBonusModel> ListSales(long site,long salesId, out string message, out int rows)
        {
            IList<SalesBonusModel> result = List( site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out  rows, Restrain.Eq("SalesId", salesId));
            return result;
        }
        public IList<SalesBonusModel> ListByOrder(long site, long salesId, out string message, out int rows)
        {
            IList<SalesBonusModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out  rows, Restrain.Eq("OrderId", salesId));
            return result;
        }
        public SalesBonusModel GetByCode(long site, string code, out string message)
        {
            IList<SalesBonusModel> result = List(site, OrderBy.GetDefault(), Limit.GetDefault(), out message, out int rows, Restrain.Eq("Code", code));
            if(result.Count>0)
                return result.First();
            return null;
        }
    }
}
